package org.xm.sk.vo.tb;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.xm.sk.vo.Base;
import org.xm.sk.vo.ob.PriceInfo;

import com.fasterxml.jackson.annotation.JsonIgnore;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
@Table(name = "dc_hairdresser")
@ApiModel(value = "Hairdresser", parent = Base.class, description = "发型师")
public class Hairdresser extends Base {

    /**
     * 
     */
    private static final long serialVersionUID = 7738479691608079121L;
    
    @ApiModelProperty(value = "发型师名称")
    @Column(length = 255)
    private String name;
    
    @ApiModelProperty(value = "发型师综合评分")
    @Column(length = 10)
    private String cmark;
    
    @ApiModelProperty(value = "所属门店")
    @JsonIgnore
    @ManyToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinColumn(name = "dc_shop_id")
    private Shop shop;
    
    @ApiModelProperty(value = "所属门店ID")
    @Transient
    private Integer shopId;
    
    @ApiModelProperty(value = "所属门店名称")
    @Transient
    private String shopName;
    
    @ApiModelProperty(value = "关联用户")
    @JsonIgnore
    @ManyToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinColumn(name = "dc_user_id")
    private User user;
    
    @ApiModelProperty(value = "关联用户ID")
    @Transient
    private Integer userId;
    
    @ApiModelProperty(value = "关联用户名")
    @Transient
    private String userName;
    
    @ApiModelProperty(value = "拥有的优惠券")
    @JsonIgnore
    @OneToMany(cascade = {
            CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "hairdresser")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Coupon> coupons = new HashSet<Coupon>(0);
    
    @ApiModelProperty(value = "发型师的服务时间点")
    @JsonIgnore
    @ManyToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinTable(name = "dc_hairdresser_server_time", joinColumns = {
            @JoinColumn(name = "dc_hairdresser_id") }, inverseJoinColumns = {
                    @JoinColumn(name = "dc_server_time_id") })
    @Fetch(FetchMode.SUBSELECT)
    private Set<ServerTime> serverTimes = new HashSet<ServerTime>(0);

    @ApiModelProperty(value = "发型师的服务时间点ID集")
    @Transient
    private Set<Integer> serverTimesIds = new HashSet<Integer>(0);
    
    @ApiModelProperty(value = "发型师的评论")
    @JsonIgnore
    @ManyToMany(cascade = {
            CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "hairdressers")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Mete> metes = new HashSet<Mete>(0);
    
    @ApiModelProperty(value = "发型师的订单")
    @JsonIgnore
    @OneToMany(cascade = {
            CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "hairdresser")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Boder> boders = new HashSet<Boder>(0);
    
    @ApiModelProperty(value = "发型师的优惠活动")
    @JsonIgnore
    @OneToMany(cascade = {
            CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "hairdresser")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Activity> activitys = new HashSet<Activity>(0);

    @ApiModelProperty(value = "发型师展示图片")
    @JsonIgnore
    @ManyToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinTable(name = "dc_hairdresser_image", joinColumns = {
            @JoinColumn(name = "dc_hairdresser_id") }, inverseJoinColumns = {
                    @JoinColumn(name = "dc_image_id") })
    @Fetch(FetchMode.SUBSELECT)
    private Set<Image> images = new HashSet<Image>(0);

    @ApiModelProperty(value = "发型师展示图片ID集")
    @Transient
    private Set<Integer> imageIds = new HashSet<Integer>(0);
    
    @ApiModelProperty(value = "发型师的作品")
    @JsonIgnore
    @OneToMany(cascade = {
            CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "hairdresser")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Works> workses = new HashSet<Works>(0);
    
    @ApiModelProperty(value = "发型师项目价格")
    @JsonIgnore
    @OneToMany(cascade = {
            CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "hairdresser")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Price> prices = new HashSet<Price>(0);
    
    @ApiModelProperty(value = "发型师项目价格")
    @Transient
    private Set<PriceInfo> priceInfos = new HashSet<PriceInfo>(0);
    
    @ApiModelProperty(value = "关注此发型师的粉丝")
    @JsonIgnore
    @ManyToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinTable(name = "dc_hairdresser_fans", joinColumns = {
            @JoinColumn(name = "dc_hairdresser_id") }, inverseJoinColumns = {
                    @JoinColumn(name = "dc_user_id") })
    @Fetch(FetchMode.SUBSELECT)
    private Set<User> fans = new HashSet<User>(0);
    
    @ApiModelProperty(value = "粉丝数量")
    @Transient
    private Integer fansCount;
    
    @ApiModelProperty(value = "发型师手机号")
    @Transient
    private String phone;
    
}
